package com.hbnu.mapper;

import com.hbnu.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    @Insert("insert into tb_user(username,password,address,balance) values(#{username},#{password},#{address},#{balance})")
    public int insertUser(User user);

    // 根据用户id修改用‘balance’字段的值
    @Update("update tb_user set balance = #{balance} where id = #{id}")
    public  int updateUserBalance(User user);

    // 根据用户id删除用户信息
    @Delete("delete from tb_user where id = #{id}")
    public int deleteUserById(Integer id);

    // 根据用户id查询用户信息
    @Select("select * from tb_user where id = #{id}")
    public User selectUserById(Integer id);

    // 查询所有用户的信息
    @Select("select * from tb_user")
    public List<User> selectAllUser();


}
